n = int(input())

arr = list(map(int, input().split()))
maxdistance = 0

for i in range(n):
    for j in range(n):
        distance = abs(arr[i] - arr[j]) + abs[i - j]
        if distance > maxdistance:
            maxdistance = distance
print(maxdistance)
